package org.example.rabbitmqserver02.handler;

import com.rabbitmq.client.Channel;
import org.example.rabbitmqserver02.config.RabbitmqConfigTest;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class RabbitmqHandlerTest {
    //监听queue_direct队列
    @RabbitListener(queues = {RabbitmqConfigTest.QUEUE_DIRECT})
    public void receive_direct(Object msg, Message message, Channel channel) {
        System.out.println("receive_direct:" + msg);
    }

    //监听queue_fanout队列 广播
    @RabbitListener(queues = {RabbitmqConfigTest.QUEUE_FANOUT_A})
    public void receive_fanout_a(Object msg, Message message, Channel channel) {
        System.out.println("receive_fanout_a:" + msg);
    }
    @RabbitListener(queues = {RabbitmqConfigTest.QUEUE_FANOUT_B})
    public void receive_fanout_b(Object msg, Message message, Channel channel) {
        System.out.println("receive_fanout_b:" + msg);
    }

    //监听queue_topic队列
    @RabbitListener(queues = {RabbitmqConfigTest.QUEUE_TOPIC})
    public void receive_topic(Object msg, Message message, Channel channel) {
        System.out.println("receive_topic:" + msg);
    }

    //监听queue_handler队列
    @RabbitListener(queues = {RabbitmqConfigTest.QUEUE_HEADERS_A})
    public void receive_headers(Object msg, Message message, Channel channel) {
        System.out.println("receive_headers:" + msg);
    }
    @RabbitListener(queues = {RabbitmqConfigTest.QUEUE_HEADERS_B})
    public void receive_headers_b(Object msg, Message message, Channel channel) {
        System.out.println("receive_headers_b:" + msg);
    }
}
